package cn.itcast.crm.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import cn.itcast.crm.domain.Customer;

public interface CustomerRepository extends JpaRepository<Customer, Integer> {
      //查找未关联定区的客户
	  public List<Customer> findByFixedAreaIdIsNull(); 
	  // 根据定区id查找客户
      public List<Customer> findByFixedAreaId(String Id);
      //根据定区id关联定区
      @Query("update Customer set fixedAreaId = ? where id = ?")
      @Modifying
      public void updateFixedAreaId(String fixedAreaId,Integer id);
      //根据客户id解除定区关联
      @Query("update Customer set fixedAreaId = null where fixedAreaId = ?")
      @Modifying
	  public void clearFixedAreaId(String fixedAreaId);
        
}
